package com.design.strategy.supermarket;

/**
 * Created by yijy on 2018/1/16.
 */
public class PriceContext {

    private PricesStrategyInterface strategyInterface;

    private static final int Type_Normal = 0x0001;
    private static final int Type_Discount = 0x0002;
    private static final int Type_ReturnPrice = 0x0003;

    public PriceContext(int type,float ...args) {
        switch (type){
            case Type_Normal:
                strategyInterface = new NormalPriceStrategy(args[0]);
                break;
            case Type_Discount:
                strategyInterface = new DiscountPriceStrategy(args[0],args[1]);
                break;
            case Type_ReturnPrice:
                strategyInterface = new ReturnPriceStrategy(args[0],args[1],args[2]);
                break;
            default:
                strategyInterface = new NormalPriceStrategy(args[0]);
        }
    }

    public float executePriceStrategy(){
        return strategyInterface.resultPrices();
    }
}
